---
version: "3"
volumes:
  nextcloud:
  db:
services:
  trojangfw:
    image: trojangfw/trojan:latest
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"
    container_name: trojan
    volumes:
      - ./appdata/config:/config
    ports:
      - 443:443
    restart: unless-stopped
    sysctls: 
      net.ipv4.tcp_fastopen: 3
    networks:
      vlan:
        ipv4_address: 10.10.0.4
    dns: 8.8.8.8

  v2ray:
    image: v2fly/v2fly-core:v4.34.0
    container_name: v2ray-docker
    volumes:
      - ./appdata/etc/v2ray/config.json:/etc/v2ray/config.json
      - ./appdata/log/v2ray:/var/log/v2ray
    ports:
      - 10443:10443
    restart: unless-stopped
    sysctls: 
      net.ipv4.tcp_fastopen: 3
    networks:
      vlan:
        ipv4_address: 10.10.0.2
    dns: 8.8.8.8
    
  letsencrypt:
    image: linuxserver/swag:version-1.11.0
    container_name: letsencrypt
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
      - URL=${DOMAIN}
      - SUBDOMAINS=
      - VALIDATION=http
      - DHLEVEL=2048 #optional
    volumes:
      - ./appdata/config:/config
    ports:
      - 81:81
      - 80:80
    restart: unless-stopped
    sysctls: 
      net.ipv4.tcp_fastopen: 3
    networks:
      vlan:
        ipv4_address: 10.10.0.3
    dns: 8.8.8.8
  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: unless-stopped
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=yourmysqlpass
      - MYSQL_PASSWORD=yourmysqlpassroot
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    networks:
      vlan:
        ipv4_address: 10.10.0.5
    dns: 8.8.8.8

  app:
    image: nextcloud
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    restart: unless-stopped
    networks:
      vlan:
        ipv4_address: 10.10.0.6
    dns: 8.8.8.8
networks:
  vlan:
    external: false
    ipam:
      config:
        - subnet: 10.10.0.0/19
